<?php
  require_once('./db.php');

  if(isset($_GET['mode']) &&
  $_GET['mode']=='del') {
    $id = $_GET['id'];
    $delQuery = "DELETE FROM `users`
    WHERE `id`='$id'";
    mysql_query($delQuery);
    if(mysql_affected_rows()==1){
      echo "Record Deleted Successfully";
    }
  }

  $query = "SELECT * FROM `users`";
  $result = mysql_query($query) or die(mysql_error());

?>
<table  border="1" cellpadding="0" cellspacing="0" width="80%" align="center">
  <thead>
    <tr>
      <th colspan="6">:: All Users  ::</th>
    </tr>
    <tr>
      <th align="left">#</th>
      <th align="left">Name</th>
      <th align="left">Email</th>
      <th align="left">Added date</th>
      <th align="left">Status</th>
      <th align="left">Action</th>
    </tr>
  </thead>
  <tbody>
<?php
  while($ans = mysql_fetch_assoc($result))
  {
    $id = $ans['id'];
?>
    <tr>
      <td><?=$id?></td>
      <td><?=$ans['name']?></td>
      <td><a href="mailto:<?=$ans['email']?>"><?=$ans['email']?></a></td>
      <td><?=date('d-M-Y G:i a',strtotime($ans['added_date']))?></td>
      <td><?=getStatus($ans['status'])?></td>
      <td>

      <a href="#">Edit</a> /

      <a onClick="return confirm('Are you sure ?');" href="display_users.php?id=<?=$id?>&mode=del">Delete</a>

      </td>
    </tr>
<?php
  }// end while
?>

  </tbody>
</table>
